package model;

/*****************************************
 * frog
 * 
 * Holds information about the character which
 * the player controls in the game
 * 
 * @author Stephen Gregory, Jun Wang
 *
 */

public abstract class gameEntity {

	private int posX;
	private int posY;
	private int velocityX;
	private boolean outOfBounds;
	private int leftBound; //the x-coordinate of the left edge of the mainFrame
	private int rightBound; //the x-coordinate of the right edge of the mainFrame
	
	public void setPos(int x, int y) {
		this.posX = x;
		this.posY = y;
	}
		
	public void setVelocityX(int x) {
		this.velocityX = x;
	}
	
	/**
	 * Method: move
	 * Purpose: change the position and check if moved
	 *          beyond the bounds
	 */
	
	public void move(double time) {
		this.posX += velocityX * time;
		hitEdgeCheck();		
	}
	
	public int getPosX() {
		return posX;
	}
	
	public int getPosY() {
		return posY;
	}
	
	/**
	 * Method: hitEdgeCheck
	 * Purpose: set a flag if the frog has hit the edge
	 */
	
	public void hitEdgeCheck() {
		if ((posX < leftBound+20) || (posX > rightBound-20)) {
			outOfBounds = true;
		}
	}
	
	public boolean outOfBounds() {
		return outOfBounds;	
	}
	
	/**
	 * Method: reset
	 * Purpose: called when the frog needs
	 *          to be set to initial position
	 */
	
	public void reset() {
		velocityX = 0;
		posX = 450;
		posY = 500;		
		outOfBounds = false;
	}

	
}
